#!/bin/bash

# Usage:
#   $1 Whether to install Vapor

mv /etc/passwd /etc/passwd.bak
mv /etc/group /etc/group.bak
cp /home/lace/tmp/passwd /etc/passwd
cp /home/lace/tmp/group /etc/group
mv /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources.bak
cp ./ubuntu.sources /etc/apt/sources.list.d/

apt update
apt install vim -y

chown -R lace:lace /home/lace # 修改容器附加卷的所有者和组，容器创建的时候默认都是root


# 下面是通过源码编译安装 vapor 工具。
install_vapor=$1
if [ -n "$install_vapor" ]; then
  apt install -y build-essential curl
  git clone https://github.com/vapor/toolbox.git
  cd toolbox
  git checkout 18.7.5
  make install
  cd ..
  rm -fr toolbox
fi

### Install Objective-C 开发环境 ###
apt install -y build-essential gcc g++
apt install -y gobjc gobjc++ gnustep gnustep-devel

# 以上脚本执行需要root权限：docker exec -it --user root swift_dev_env /bin/bash
